package process

import (
	"github.com/lishimeng/go-log"
	"strconv"
	"strings"
)

func InputConvert(line []string) (tmp KeywordsInput) {
	tmp.CustomSearch = getField(line, 3)
	tmp.Click = getNumber(getField(line, 11))
	tmp.Show = getNumber(getField(line, 12))
	tmp.Order = getNumber(getField(line, 16))

	tmp.Cost = getMoney(getField(line, 14))
	tmp.TotalSales = getMoney(getField(line, 17))
	return
}

func getNumber(s string) (i int64) {
	i, err := strconv.ParseInt(s, 0, 64)
	if err != nil {
		log.Debug(err)
	}
	return
}

func getMoney(s string) (m float64) {
	s = strings.ReplaceAll(s, "$", "")
	m, err := strconv.ParseFloat(s, 64)
	if err != nil {
		log.Debug(err)
	}
	return
}
